<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>验证码</h1>
    <div id="img"></div>
    <p>
        账号：
        <input id="loginId" type="text">
    </p>
    <p>
        密码：
        <input type="text" id="loginPwd">
    </p>
    <p>
        验码：
        <input type="text" id="captcha">
    </p>
    <button id="btn">登录</button>

    <script>
        fetch("http://localhost:8002/res/captcha")
            .then(resp => resp.json())
            .then(resp => {
                img.innerHTML = resp.data
            })

        btn.onclick = function (params) {
            const myloginId = loginId.value;
            const myloginPwd = loginPwd.value;
            const mycaptcha = captcha.value;

            const body = {
                loginId: myloginId,
                loginPwd: myloginPwd,
                captcha: mycaptcha
            }

            fetch("http://localhost:8002/api/admin/login", {
                method: "post",
                headers: {
                    "Content-Type": "application/json",
                },
                body: JSON.stringify(body)
            })
            .then(resp => resp.json())
            .then(resp => {
                console.log(resp);
            })
        }
    </script>
</body>

</html>